<template>
  <div class="box">
    <!-- 导航头 -->
    <navbar></navbar>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        placeholder="账号名/邮箱/手机号"
        :rules="[{ required: true, message: '账号名/邮箱/手机号' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        placeholder="请输入密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      ></van-field>
      <div style="margin: 16px">
        <van-button round block type="danger" native-type="submit"
          >登录</van-button
        >
      </div>
      <img src="@/assets/img/login/d.png" alt="" width="150px" />
    </van-form>
  </div>
</template>

<script>
import navbar from "@/components/navbar.vue";
import { Toast } from "vant";
export default {
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    onSubmit(values) {
      console.log("submit", values);
      if (values.username === "douzi" && values.password === "123123") {
        this.$router.push({ name: "main" });
      } else {
        Toast.fail("密码错误");
      }
    },
  },
  components: {
    navbar,
  },
};
</script>

<style  scoped>
.van-field {
  margin-top: 20px;
  padding-left: 30px;
  font-size: 16px;
}
.van-button {
  background-image: -webkit-gradient(
    linear,
    left top,
    right top,
    color-stop(0, #fab3b3),
    color-stop(73%, #ffbcb3),
    to(#ffcaba)
  );
  border: none;
}
img {
  margin: 120px;
}
</style>